<template>
	<view class="content">
		<view class="wid100" style="height: 294rpx;background-color: #37BCC3;">
			<view style="height: 56rpx;"></view>
			<view class="wid90 mar dis fowe600 coFFF">
				<view class="wid33 dis">
					<view class="textCen">
						<view class="foSi50">{{today_count}}</view>
						<view class="mar-top10 foSi25">今日新增</view>
					</view>
				</view>
				<view class="wid33 dis disJuC">
					<view class="textCen">
						<view class="foSi50">{{yesterday}}</view>
						<view class="mar-top10 foSi25">昨日新增</view>
					</view>
				</view>
				<view class="wid33 dis" style="justify-content: flex-end;">
					<view class="textCen">
						<view class="foSi50">{{count}}</view>
						<view class="mar-top10 foSi25">总会员量</view>
					</view>
				</view>
			</view>
			<input class="wid90 mar hei60 textCen bacFFF borRad40 mar-top40" v-model="suosou" @input="suosouInput" placeholder="搜索会员" />
		</view>
		<scroll-view style="height: calc(100vh - 294rpx);" class="wid100" scroll-y="true" @scrolltolower="lower">
			<view style="height: 10rpx;"></view>
			<block v-for="(item,index) in list" :key="index">
				<view class="wid90 mar bacFFF borRad20 mar-top30 poRel" 
					style="padding: 25rpx 0;" @click="tiaozhuan('/pages/member/particulars?id='+item.id)">
					<view class=" wid90 mar">
						<view class="dis disAl">
							<view style="width: 25%;height: 128rpx;">
								<image :src="url+item.avatar" class="borRad50 hei100" style="width: 128rpx;"></image>
							</view>
							<view style="width: 75%;">
								<view class="dis disAl disJuB">
									<view class="foSi40 fowe600 nowrap">{{item.nickname}}</view>
									<view class="foSi25 fowe600" style="color: #37BCC3;">{{item.level_name}}</view>
								</view>
								<view class="foSi30 fowe600 mar-top10">{{item.mobile}}</view>
								<view class="foSi20 mar-top10" style="opacity: 0.8;">注册时间：{{item.createtime}}</view>
							</view>
						</view>
					</view>
					<view class="xia mar-top30"></view>
					<view class="mar-top20 wid80 mar dis fowe600" style="justify-content: space-around;">
						<view class="textCen">
							<view class="foSi30">{{item.money}}</view>
							<view class="mar-top10 foSi20">钱包</view>
						</view>
						<view class="textCen">
							<view class="foSi30">{{item.coupon_log_count}}</view>
							<view class="mar-top10 foSi20">优惠券</view>
						</view>
					</view>
				</view>
			</block>
			<view style="height: 50rpx;"></view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				url: this.global.url,
				timer: null,
				suosou: '',
				last_page: 0,
				page: 1,
				list: [],
				today_count: 0,
				yesterday: 0,
				count: 0
			}
		},
		onLoad() {
			this.yuan_userinfo = uni.getStorageSync('yuan_userinfo')
			this.getList()
		},
		onShow() {},
		methods: {
			getList() {
				var that = this;
				uni.request({
					url: that.global.url + '/api/qianyu_petrol/gasstation_clerk_user_list',
					method: "POST",
					header: {
						'site-id': that.global.site_id,//自定义请求头信息
						'token': uni.getStorageSync('token')
					},
					data: {
						gas_station_id: that.yuan_userinfo.gas_station_id,
						search: that.suosou,
						page: that.page,
							limit: 10,
							clerk_id: that.yuan_userinfo.id
					},
					success(res) {
						let result = res.data
						console.log(result)
						if (result.code == 1) {
							that.last_page = result.data.list.last_page
							that.list = that.list.concat(result.data.list.data)
							that.today_count = result.data.today_count
							that.yesterday = result.data.yesterday
							that.count = result.data.count
						}
					}
				})
			},
			suosouInput: function(event) {
				var that = this
				if (that.timer !== null) clearTimeout(that.timer)
				that.timer = setTimeout(() => {
					that.suosou = event.target.value
					console.log(that.suosou)
					that.list = []
					that.getList()
				}, 1000)
			},
			lower(e) {
				if(this.last_page > this.page){
					this.page++
					this.getList()
				}
			},
			tiaozhuan(url) {
				uni.navigateTo({
					url: url
				})
			}
		}
	}
</script>

<style>
	.content {
		background: #F8F9FD;
		height: 100vh;
	}
	.xia{
		height: 1rpx;
		background-color: #E5E5E5;
	}
	.nowrap{
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
		width: 150px;
	}
</style>
